package cn.northsea.controller;

import cn.northsea.common.Result;
import cn.northsea.entity.Appeal;
import cn.northsea.service.AppealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static cn.northsea.common.enums.ResultCodeEnum.SUCCESS;

@RequestMapping("/appeal")
@CrossOrigin
@RestController
public class AppealController {
    @Autowired
    AppealService appealService;
    @GetMapping("/getList")
    public Result getList(){
       List<Appeal>  appealList = appealService.findAll();
        return Result.success(appealList);
    }
    @GetMapping("/updateAppelByState")
    public Result updateAppelByState(Integer id,Integer zt){
        appealService.updateAppelByState(id,zt);
        return Result.success(SUCCESS);
    }
    @PostMapping("/addAppeal")
    public Result addAppeal(@RequestBody Appeal appeal){
          appealService.addAppeal(appeal);
          return Result.success(SUCCESS);
    }
    @GetMapping("/getListById")
    public Result getListById(Integer id){
        List<Appeal>  appealList = appealService.getListById(id);
        return Result.success(appealList);
    }
}
